
#include "LoadScreen.h"
#include "Screen.h"
#include "TextureManager.h"
#include <gl\glut.h>

LoadScreen::LoadScreen()
{
	int i = 0;
 	m_rotation = 0;
	m_texPath = "Textures/HUDPanel.png";
	m_iconTexPath = "Textures/LoadIconWheel.png";

	//LoadText();
}

LoadScreen::~LoadScreen()
{
	
}

void LoadScreen::Draw()
{
	
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	glDisable(GL_DEPTH_TEST);
	glDisable(GL_LIGHTING);
	glDisable(GL_LIGHT0);

	glMatrixMode (GL_MODELVIEW);

	glPushMatrix ();
	glLoadIdentity ();

		glMatrixMode (GL_PROJECTION);
			glLoadIdentity ();
			//Draw load background
			glPushMatrix ();
					

			TheTextureManager::Instance()->DrawTexture(m_texPath);

			glBegin (GL_QUADS);
			glTexCoord2f(0,0);
			glVertex3f (-1, 1, -1);
			glTexCoord2f(1, 0);
			glVertex3f (1, 1, -1);
			glTexCoord2f(1,1);
			glVertex3f (1, -1, -1);
			glTexCoord2f(0,1);
			glVertex3f (-1, -1, -1);

			glEnd ();
			glPopMatrix ();

			//Draw rotating Icon

			TheTextureManager::Instance()->DrawTexture(m_iconTexPath);

			glPushMatrix();

			glScalef(1, 1.15f, 1);
			glRotatef(m_wheelRotation, 0, 0, 1);

			glBegin(GL_QUADS);

			glTexCoord2f(0,0);
			glVertex3f (-0.5f, 0.5f, -1);
			glTexCoord2f(0, 1);
			glVertex3f (-0.5f, -0.5f, -1);
			glTexCoord2f( 1, 1);
			glVertex3f(0.5f, -0.5f, -1);
			glTexCoord2f( 1, 0);
			glVertex3f(0.5f, 0.5f, -1);

			m_wheelRotation += 0.5f;

			glEnd();
			glPopMatrix();

	glMatrixMode (GL_MODELVIEW);
	glPopMatrix ();

	glEnable(GL_DEPTH_TEST);
	glEnable(GL_LIGHTING);
	glEnable(GL_LIGHT0);

}

void LoadScreen::IncrementDraw()
{
	m_rotation += 0.25f;
	Draw();
	TheScreen::Instance()->Flip();
}


